
#include "stm32f0xx_conf.h"


//------------------------------------------------------------------------------
// Function Name : delay_ms
// Description : delay for some time in ms unit(accurate)
// Input : n_ms is how many ms of time to delay
//------------------------------------------------------------------------------
static uint32_t msTick =0;

void SysTick_Handler()
{
	msTick++;
}

void delay(uint32_t ms)
{
	uint32_t start = msTick;
	while ((msTick - start) < ms);
}
void initgpio()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_5 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
GPIO_Init(GPIOB, &GPIO_InitStructure);
}

void display(int b)
{
switch(b)
{
case 0: GPIOA->ODR = 0x0007; //0
GPIOC->ODR = 0x0007;
delay(1000);
break;
case 1:
GPIOA->ODR = 0x0001; //1
GPIOC->ODR = 0x0004;
delay(1000);
break;
case 2:
GPIOA->ODR = 0x000B; //2
GPIOC->ODR = 0x0003;
delay(1000);
break;
case 3:
GPIOA->ODR = 0x000B; //3
GPIOC->ODR = 0x0006;
delay(1000);
break;
case 4: 
GPIOA->ODR = 0x000D; //4
GPIOC->ODR = 0x0004;
delay(1000);
break;
case 5:
GPIOA->ODR = 0x000E; //5
GPIOC->ODR = 0x0006;
delay(1000);
break;
case 6:
GPIOA->ODR = 0x000E; //6
GPIOC->ODR = 0x0007;
delay(1000);
break;
case 7: 
GPIOA->ODR = 0x0003; //7
GPIOC->ODR = 0x0004;
delay(1000);
break;
case 8:
GPIOA->ODR = 0x000F; //8
GPIOC->ODR = 0x0007;
delay(1000);
break;
case 9:
GPIOA->ODR = 0x000F; //9
GPIOC->ODR = 0x0006;
delay(1000); 
break;
case 10:
GPIOA->ODR = 0x000F; //*
GPIOC->ODR = 0x0000;
delay(1000);
break;
case 11:
GPIOA->ODR = 0x0008; //#
GPIOC->ODR = 0x000F;
delay(1000);
break;
}
return ;
}


